From b7a98fbaa9bd2c8d9fafbe3090bc2c0a8a09dde5 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 16 Dec 2022 15:39:02 +0700 Subject: no message --- src/pages/shop/brands/[slug].js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/pages/shop/brands/[slug].js') diff --git a/src/pages/shop/brands/[slug].js b/src/pages/shop/brands/[slug].js index b04d2715..a2f05cfa 100644 --- a/src/pages/shop/brands/[slug].js +++ b/src/pages/shop/brands/[slug].js @@ -1,5 +1,5 @@ import axios from "axios"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import Filter from "../../../components/Filter"; import Header from "../../../components/Header"; import Layout from "../../../components/Layout"; @@ -58,6 +58,7 @@ export default function BrandDetail({ const productFound = searchResults.response.numFound; const [activeFilter, setActiveFilter] = useState(false); + const [filterCount, setFilterCount] = useState(0); const route = () => { let route = `/shop/brands/${slug}`; @@ -68,6 +69,14 @@ export default function BrandDetail({ return route; } + useEffect(() => { + let calculateFilterCount = 0; + if (category) calculateFilterCount++; + if (price_from || price_to) calculateFilterCount++; + if (order_by) calculateFilterCount++; + setFilterCount(calculateFilterCount); + }, [category, price_from, price_to, order_by]); + return ( <>
@@ -85,9 +94,6 @@ export default function BrandDetail({ />
-

Produk

{productFound > 0 ? ( @@ -106,6 +112,9 @@ export default function BrandDetail({ ) : 'Mungkin yang anda cari'}
+
{searchResults.response.products.map((product) => ( -- cgit v1.2.3